/*Boyer-Moore 投票算法*/
import java.util.*;
public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.nextLine().trim().split(" ");
        int len = s.length;
        int[] nums = new int[len];
        for (int i = 0; i < len; ++i) {
            nums[i] = Integer.parseInt(s[i]);
        }
        System.out.println(majorityElement2(nums));
    }

    public int majorityElement(int[] nums) {


        int res = 0;
        int count = 0;
        /*注意不涉及下标可以用for*/
        for (int num : nums) {
            if (count == 0) {
                res = num;
                // count++;  错在多加了一个
            }
            if (res == num) {
                count++;
            } else {
                count--;
            }

        }
        return res;
    }
    /*写错*/
    public static int majorityElement2(int[] nums) {
        int res = nums[0];
        int count = 1;
        for (int i = 1; i < nums.length; ++i) {
            if (nums[i] == res) {
                count++;
            } else {
                count--;
                if (count == 0) res = nums[i];
            }
        }
        return res;
    }
}
